<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas id="c1" height="800" width="800">
        你的浏览器不支持canvas
    </canvas>

    <script>
        let c1 = document.getElementById('c1')
        let ctx = c1.getContext('2d')//别忘了”二弟“

        // 填充模式会给矩形的内部也上色
        ctx.fillRect(100,100,300,300);

        // 也可以拆开来写
        // ctx.rect(100,100,300,300);
        // ctx.fill()
    </script>
</body>
</html>